<?php
// +----------------------------------------------------------------------
// | Archives(日志归档
// +----------------------------------------------------------------------
// | @link ( http://www.yurnero.net )
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: ArchivesWidget.class.php 101 2011-04-22 10:10:57Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class ArchivesWidget extends Widget {

	/**
	 * 构造日志归档
	 * 
	 */
	public function render($data) {
	
		$posts =  f_static_cache('posts_static','',ROOT_PATH . STATIC_CACHES_DIR);
	    $output = '';
		$output .= '<!-- Archives: START -->'."\n";
		$output .= " <li class=\"widget widget_archive dbx-box\">\n";
		$output .= "  <h3 class=\"dbx-handle\">Archives</h3>\n";
		$output .= "   <ul class='dbx-content'>\n";
		foreach ($posts as $k=>$v) {
			$output .= "    <li>";
			$output	.= '<a href='.__APP__.'/Archives/'.$this->dateStrReplace($k).'/ title="'.$k.'">'.$k.'</a>&nbsp;&nbsp;['.$v.']';
			$output .= "</li>\n";
		}
		$output .= "   </ul>\n";
		$output .= " </li>\n";
		$output .= ' <!-- Archives: END -->'."\n";
		
		return $output;
	}
	
	protected function dateStrReplace($str) {
		return str_replace('-','/',$str);
	}
	
}

?>
